<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/common/taglibs.jsp"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta charset="utf-8">
	<title>客户信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="${ctxLayui}/layuiadmin/layui/css/layui.css" media="all">
	<link rel="stylesheet" href="${ctxLayui}/layuiadmin/style/admin.css" media="all">
	<link rel="stylesheet" href="${ctxLayui}/layuiadmin/style/myStyle.css" media="all">

	<script src="${ctxLayui}/webphone/jquery-1.11.3.min.js" type="text/javascript"></script>
	<script src="${ctxLayui}/webphone/call.js?v=1" type="text/javascript"></script>

	<script src="${ctxLayui}/webphone/xSoftphone.js" type="text/javascript"></script>
	<script src="${ctxLayui}/webphone/sip-0.11.6.js" type="text/javascript"></script>

	<script src="${ctxLayui}/webphone/janus.js" type="text/javascript"></script>
	<script src="${ctxLayui}/webphone/webrtc2sip.js?v=1" type="text/javascript"></script>
	<script src="${ctxLayui}/webphone/adapter.min.js" type="text/javascript"></script>

	<script src="${ctxLayui}/webphone/md5.min.js" type="text/javascript"></script>
	<script src="${ctxLayui}/webphone/spin.min.js" type="text/javascript"></script>
	<script src="${ctxLayui}/webphone/toastr.min.js" type="text/javascript"></script>
</head>

<body class="layui-layout-body">

<audio id="hangupSound" src="${ctxLayui}/webphone/audio/hangup.mp3" loop=""></audio>
<audio id="ring-tone" src="${ctxLayui}/webphone/audio/incoming.mp3" loop=""></audio>
<audio id="ringback-tone" src="${ctxLayui}/webphone/audio/outgoing.mp3" loop=""></audio>
<audio id="audio-remote"></audio>
<audio id="audio-local"></audio>


<input type="hidden" id="seatStatus" >
<input type="hidden" id="channelId" >
<input type="hidden" id="channelPwd" >

<input type="hidden" id="seatHost" >
<input type="hidden" id="seatPort">
<input type="hidden" id="seatType" />
<input type="hidden" id="callMobile" value="18159166320" />
<input type="hidden" id="callType"  />

<div id="videos" style="display:none">
	<div class="col-md-6">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title"></h3>
			</div>
			<div class="panel-body" id="videoleft" hidden="true"></div>
		</div>

		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title"></h3>
			</div>
			<div class="panel-body" id="videoright" hidden="true"></div>
		</div>
	</div>
</div>

<div class="layui-card layadmin-header">
	<div class="layui-breadcrumb" lay-filter="breadcrumb">
		<!--<a lay-href="">xx管理</a>-->
		<a><cite>客户信息</cite></a>
	</div>
</div>

<div class="layui-fluid">
	<div class="layui-card">

		<div class="layui-collapse" lay-filter="component-panel">
			<div class="layui-colla-item">
				<h2 class="layui-colla-title">搜索条件</h2>
				<div class="layui-colla-content">
					<div class="layui-form layui-card-header layuiadmin-card-header-auto">
						<div class="layui-form-item">
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">客户编号</label>
								<div class="layui-input-block">
									<input class="layui-input" name="customerNo" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">名称</label>
								<div class="layui-input-block">
									<input class="layui-input" name="name" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">信用代码</label>
								<div class="layui-input-block">
									<input class="layui-input" name="creditCode" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">注册时间</label>
								<div class="layui-input-block">
									<input class="layui-input" name="issueTime" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">法人</label>
								<div class="layui-input-block">
									<input class="layui-input" name="faRen" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">注册资金 (万元 )</label>
								<div class="layui-input-block">
									<input class="layui-input" name="regMoney" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">客户类型Id</label>
								<div class="layui-input-block">
									<input class="layui-input" name="customerTypeId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">客户类型</label>
								<div class="layui-input-block">
									<input class="layui-input" name="customerType" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">公司分类Id</label>
								<div class="layui-input-block">
									<input class="layui-input" name="companyCattegoryId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">公司分类</label>
								<div class="layui-input-block">
									<input class="layui-input" name="companyCattegory" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">所属行业Id</label>
								<div class="layui-input-block">
									<input class="layui-input" name="industryId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">所属行业</label>
								<div class="layui-input-block">
									<input class="layui-input" name="industry" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">纳税人类型;1-一般;2-小规模</label>
								<div class="layui-input-block">
									<input class="layui-input" name="taxpayerType" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">详细地址</label>
								<div class="layui-input-block">
									<input class="layui-input" name="address" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">联系人</label>
								<div class="layui-input-block">
									<input class="layui-input" name="contacts" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">固定电话</label>
								<div class="layui-input-block">
									<input class="layui-input" name="telephone" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">移动电话</label>
								<div class="layui-input-block">
									<input class="layui-input" name="mobile" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">邮箱</label>
								<div class="layui-input-block">
									<input class="layui-input" name="email" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">微信号</label>
								<div class="layui-input-block">
									<input class="layui-input" name="wechatNo" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">QQ</label>
								<div class="layui-input-block">
									<input class="layui-input" name="qq" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">客户网址</label>
								<div class="layui-input-block">
									<input class="layui-input" name="website" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">部门</label>
								<div class="layui-input-block">
									<input class="layui-input" name="department" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">部门Id</label>
								<div class="layui-input-block">
									<input class="layui-input" name="departmentId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">归属用户Id</label>
								<div class="layui-input-block">
									<input class="layui-input" name="userId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">归属用户名称</label>
								<div class="layui-input-block">
									<input class="layui-input" name="userName" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">区域</label>
								<div class="layui-input-block">
									<input class="layui-input" name="region" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">区域Id</label>
								<div class="layui-input-block">
									<input class="layui-input" name="regionId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">省份代码</label>
								<div class="layui-input-block">
									<input class="layui-input" name="provinceCode" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">省份名称</label>
								<div class="layui-input-block">
									<input class="layui-input" name="provinceName" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">城市代码</label>
								<div class="layui-input-block">
									<input class="layui-input" name="cityName" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">城市代码</label>
								<div class="layui-input-block">
									<input class="layui-input" name="cityCode" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">区域名称</label>
								<div class="layui-input-block">
									<input class="layui-input" name="areaName" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">区域代码</label>
								<div class="layui-input-block">
									<input class="layui-input" name="areaCode" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">意向度Id</label>
								<div class="layui-input-block">
									<input class="layui-input" name="intentionId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">意向度</label>
								<div class="layui-input-block">
									<input class="layui-input" name="intention" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">意向时间</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" id="intentionTime-laydate-range" placeholder=" - ">
									<input type="hidden" name="intentionTimeStart">
									<input type="hidden" name="intentionTimeEnd">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">标签</label>
								<div class="layui-input-block">
									<input class="layui-input" name="labels" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">决策类型Id</label>
								<div class="layui-input-block">
									<input class="layui-input" name="decisionTypeId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">决策类型</label>
								<div class="layui-input-block">
									<input class="layui-input" name="decisionType" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">标记;1-空号;2-错号;3-同行</label>
								<div class="layui-input-block">
									<select name="tag"  id="tag" >
									</select>
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">标记状态;1-未审核;2-已审核</label>
								<div class="layui-input-block">
									<select name="tagStatus"  id="tagStatus" >
									</select>
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">释放人Id</label>
								<div class="layui-input-block">
									<input class="layui-input" name="releaseId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">释放时间</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" id="releaseTime-laydate-range" placeholder=" - ">
									<input type="hidden" name="releaseTimeStart">
									<input type="hidden" name="releaseTimeEnd">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">释放类型;1-个人;2-系统</label>
								<div class="layui-input-block">
									<select name="releaseType"  id="releaseType" >
									</select>
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">预约拜访时间</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" id="nextVisitTime-laydate-range" placeholder=" - ">
									<input type="hidden" name="nextVisitTimeStart">
									<input type="hidden" name="nextVisitTimeEnd">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">最后拜访内容</label>
								<div class="layui-input-block">
									<input class="layui-input" name="lastVisit" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">最后拜访时间</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" id="lastVisitTime-laydate-range" placeholder=" - ">
									<input type="hidden" name="lastVisitTimeStart">
									<input type="hidden" name="lastVisitTimeEnd">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">拜访状态1-未拜访;2-已拜访</label>
								<div class="layui-input-block">
									<select name="visitStatus"  id="visitStatus" >
									</select>
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">拜访次数</label>
								<div class="layui-input-block">
									<select name="visitTimes"  id="visitTimes" >
									</select>
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">总呼叫次数</label>
								<div class="layui-input-block">
									<select name="totalCallTime"  id="totalCallTime" >
									</select>
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">最后通话时间</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" id="lastCallTime-laydate-range" placeholder=" - ">
									<input type="hidden" name="lastCallTimeStart">
									<input type="hidden" name="lastCallTimeEnd">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">签约人</label>
								<div class="layui-input-block">
									<input class="layui-input" name="signId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">财税顾问</label>
								<div class="layui-input-block">
									<input class="layui-input" name="adviserId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">采集人</label>
								<div class="layui-input-block">
									<input class="layui-input" name="gatherId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">数据来源Id</label>
								<div class="layui-input-block">
									<input class="layui-input" name="dataSourceId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">数据来源</label>
								<div class="layui-input-block">
									<input class="layui-input" name="dataSource" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">入库时间</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" id="addTime-laydate-range" placeholder=" - ">
									<input type="hidden" name="addTimeStart">
									<input type="hidden" name="addTimeEnd">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">保护状态;1-未保护;2-已保持</label>
								<div class="layui-input-block">
									<select name="protectStatus"  id="protectStatus" >
									</select>
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">保护时间</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" id="protectTime-laydate-range" placeholder=" - ">
									<input type="hidden" name="protectTimeStart">
									<input type="hidden" name="protectTimeEnd">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">签约状态;1-未签约;2-签约中;3-已签约;</label>
								<div class="layui-input-block">
									<select name="signStatus"  id="signStatus" >
									</select>
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">会计状态;1-无;2-个人;3-公司;4- 外包</label>
								<div class="layui-input-block">
									<select name="accountType"  id="accountType" >
									</select>
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">类型;1-客户;2-团队;3-公海;4-失效</label>
								<div class="layui-input-block">
									<select name="type"  id="type" >
									</select>
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">推荐客户ID</label>
								<div class="layui-input-block">
									<input class="layui-input" name="recommendId" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">推荐客户名</label>
								<div class="layui-input-block">
									<input class="layui-input" name="recommendName" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">状态;1-正常;2-失效</label>
								<div class="layui-input-block">
									<select name="status"  id="status" >
									</select>
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">创建时间</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" id="createTime-laydate-range" placeholder=" - ">
									<input type="hidden" name="createTimeStart">
									<input type="hidden" name="createTimeEnd">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">修改时间</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" id="modifyTime-laydate-range" placeholder=" - ">
									<input type="hidden" name="modifyTimeStart">
									<input type="hidden" name="modifyTimeEnd">
								</div>
							</div>
							<div class="layui-inline layui-inline-31">
								<label class="layui-form-label">备注描述</label>
								<div class="layui-input-block">
									<input class="layui-input" name="remark" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline layui-inline-8">
								<button class="layui-btn" lay-submit lay-filter="customer-list-search">
									<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
								</button>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="layui-card-body">
			<div style="width: 100%;overflow-x: auto;">
				<table class="layui-hide" id="customerListTable" lay-filter="customerListTable"></table>
			</div>



			<script type="text/html" id="customerListTable-toolbar">
				<div class="layui-btn-container">
					<shiro:hasPermission name="customer:add">
						<button class="layui-btn layui-btn-sm" lay-event="addRec">添加</button>
					</shiro:hasPermission>
					<shiro:hasPermission name="customer:del">
						<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delRec">删除</button>
					</shiro:hasPermission>
				</div>
			</script>

			<script type="text/html" id="customerListTable-bar">
				<shiro:hasPermission name="customer:edit">
					<a class="layui-btn layui-btn-xs" lay-event="editRec">编辑</a>
				</shiro:hasPermission>
				<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="showRec">查看</a>
			</script>

		</div>
	</div>
</div>
<script src="${ctxLayui}/layuiadmin/layui/layui.js"></script>
<script>
	layui.config({
		base: '${ctxLayui}/layuiadmin/'
	}).extend({
		index: 'lib/index'
	}).use(['index', 'table','dict','laydate','util'], function(){
		var $ = layui.$,table = layui.table,form = layui.form;
		var dict = layui.dict;
		var laydate = layui.laydate;
		var admin = layui.admin;
		var util = layui.util;
		dict.setSelect("tag","tag");
		dict.setSelect("tagStatus","tagStatus");
		dict.setSelect("releaseType","releaseType");
		dict.setSelect("visitStatus","visitStatus");
		dict.setSelect("visitTimes","visitTimes");
		dict.setSelect("totalCallTime","totalCallTime");
		dict.setSelect("protectStatus","protectStatus");
		dict.setSelect("signStatus","signStatus");
		dict.setSelect("accountType","accountType");
		dict.setSelect("type","type");
		dict.setSelect("status","status");
		laydate.render({
			elem: '#intentionTime-laydate-range' ,
			range: true,
			done: function(value, date, endDate){
				if(!value){
					$(".layui-form-item [name=intentionTimeStart]").val(null);
					$(".layui-form-item [name=intentionTimeEnd]").val(null);
					return;
				}
				var dateStr1= value.split(" - ")[0]
				var dateStr2= value.split(" - ")[1]
				$(".layui-form-item [name=intentionTimeStart]").val(dateStr1);
				$(".layui-form-item [name=intentionTimeEnd]").val(dateStr2);
			}
		});
		laydate.render({
			elem: '#releaseTime-laydate-range' ,
			range: true,
			done: function(value, date, endDate){
				if(!value){
					$(".layui-form-item [name=releaseTimeStart]").val(null);
					$(".layui-form-item [name=releaseTimeEnd]").val(null);
					return;
				}
				var dateStr1= value.split(" - ")[0]
				var dateStr2= value.split(" - ")[1]
				$(".layui-form-item [name=releaseTimeStart]").val(dateStr1);
				$(".layui-form-item [name=releaseTimeEnd]").val(dateStr2);
			}
		});
		laydate.render({
			elem: '#nextVisitTime-laydate-range' ,
			range: true,
			done: function(value, date, endDate){
				if(!value){
					$(".layui-form-item [name=nextVisitTimeStart]").val(null);
					$(".layui-form-item [name=nextVisitTimeEnd]").val(null);
					return;
				}
				var dateStr1= value.split(" - ")[0]
				var dateStr2= value.split(" - ")[1]
				$(".layui-form-item [name=nextVisitTimeStart]").val(dateStr1);
				$(".layui-form-item [name=nextVisitTimeEnd]").val(dateStr2);
			}
		});
		laydate.render({
			elem: '#lastVisitTime-laydate-range' ,
			range: true,
			done: function(value, date, endDate){
				if(!value){
					$(".layui-form-item [name=lastVisitTimeStart]").val(null);
					$(".layui-form-item [name=lastVisitTimeEnd]").val(null);
					return;
				}
				var dateStr1= value.split(" - ")[0]
				var dateStr2= value.split(" - ")[1]
				$(".layui-form-item [name=lastVisitTimeStart]").val(dateStr1);
				$(".layui-form-item [name=lastVisitTimeEnd]").val(dateStr2);
			}
		});
		laydate.render({
			elem: '#lastCallTime-laydate-range' ,
			range: true,
			done: function(value, date, endDate){
				if(!value){
					$(".layui-form-item [name=lastCallTimeStart]").val(null);
					$(".layui-form-item [name=lastCallTimeEnd]").val(null);
					return;
				}
				var dateStr1= value.split(" - ")[0]
				var dateStr2= value.split(" - ")[1]
				$(".layui-form-item [name=lastCallTimeStart]").val(dateStr1);
				$(".layui-form-item [name=lastCallTimeEnd]").val(dateStr2);
			}
		});
		laydate.render({
			elem: '#addTime-laydate-range' ,
			range: true,
			done: function(value, date, endDate){
				if(!value){
					$(".layui-form-item [name=addTimeStart]").val(null);
					$(".layui-form-item [name=addTimeEnd]").val(null);
					return;
				}
				var dateStr1= value.split(" - ")[0]
				var dateStr2= value.split(" - ")[1]
				$(".layui-form-item [name=addTimeStart]").val(dateStr1);
				$(".layui-form-item [name=addTimeEnd]").val(dateStr2);
			}
		});
		laydate.render({
			elem: '#protectTime-laydate-range' ,
			range: true,
			done: function(value, date, endDate){
				if(!value){
					$(".layui-form-item [name=protectTimeStart]").val(null);
					$(".layui-form-item [name=protectTimeEnd]").val(null);
					return;
				}
				var dateStr1= value.split(" - ")[0]
				var dateStr2= value.split(" - ")[1]
				$(".layui-form-item [name=protectTimeStart]").val(dateStr1);
				$(".layui-form-item [name=protectTimeEnd]").val(dateStr2);
			}
		});
		laydate.render({
			elem: '#createTime-laydate-range' ,
			range: true,
			done: function(value, date, endDate){
				if(!value){
					$(".layui-form-item [name=createTimeStart]").val(null);
					$(".layui-form-item [name=createTimeEnd]").val(null);
					return;
				}
				var dateStr1= value.split(" - ")[0]
				var dateStr2= value.split(" - ")[1]
				$(".layui-form-item [name=createTimeStart]").val(dateStr1);
				$(".layui-form-item [name=createTimeEnd]").val(dateStr2);
			}
		});
		laydate.render({
			elem: '#modifyTime-laydate-range' ,
			range: true,
			done: function(value, date, endDate){
				if(!value){
					$(".layui-form-item [name=modifyTimeStart]").val(null);
					$(".layui-form-item [name=modifyTimeEnd]").val(null);
					return;
				}
				var dateStr1= value.split(" - ")[0]
				var dateStr2= value.split(" - ")[1]
				$(".layui-form-item [name=modifyTimeStart]").val(dateStr1);
				$(".layui-form-item [name=modifyTimeEnd]").val(dateStr2);
			}
		});
		var tplIntentionTime = function(d){
			if(d.modifyTime){
				return util.toDateString(d.modifyTime);
			}
			return '';
		};
		var tplTag = function(d){
			var html = dict.showName("tag",d.tag);
			return html;
		};
		var tplTagStatus = function(d){
			var html = dict.showName("tagStatus",d.tagStatus);
			return html;
		};
		var tplReleaseTime = function(d){
			if(d.modifyTime){
				return util.toDateString(d.modifyTime);
			}
			return '';
		};
		var tplReleaseType = function(d){
			var html = dict.showName("releaseType",d.releaseType);
			return html;
		};
		var tplNextVisitTime = function(d){
			if(d.modifyTime){
				return util.toDateString(d.modifyTime);
			}
			return '';
		};
		var tplLastVisitTime = function(d){
			if(d.modifyTime){
				return util.toDateString(d.modifyTime);
			}
			return '';
		};
		var tplVisitStatus = function(d){
			var html = dict.showName("visitStatus",d.visitStatus);
			return html;
		};
		var tplVisitTimes = function(d){
			var html = dict.showName("visitTimes",d.visitTimes);
			return html;
		};
		var tplTotalCallTime = function(d){
			var html = dict.showName("totalCallTime",d.totalCallTime);
			return html;
		};
		var tplLastCallTime = function(d){
			if(d.modifyTime){
				return util.toDateString(d.modifyTime);
			}
			return '';
		};
		var tplAddTime = function(d){
			if(d.modifyTime){
				return util.toDateString(d.modifyTime);
			}
			return '';
		};
		var tplProtectStatus = function(d){
			var html = dict.showName("protectStatus",d.protectStatus);
			return html;
		};
		var tplProtectTime = function(d){
			if(d.modifyTime){
				return util.toDateString(d.modifyTime);
			}
			return '';
		};
		var tplSignStatus = function(d){
			var html = dict.showName("signStatus",d.signStatus);
			return html;
		};
		var tplAccountType = function(d){
			var html = dict.showName("accountType",d.accountType);
			return html;
		};
		var tplType = function(d){
			var html = dict.showName("type",d.type);
			return html;
		};
		var tplStatus = function(d){
			var html = dict.showName("status",d.status);
			return html;
		};
		var tplCreateTime = function(d){
			if(d.modifyTime){
				return util.toDateString(d.modifyTime);
			}
			return '';
		};
		var tplModifyTime = function(d){
			if(d.modifyTime){
				return util.toDateString(d.modifyTime);
			}
			return '';
		};

		var tableIns = table.render({
			elem:'#customerListTable'
			,url: ctx+'/customer/customer/query'
			,cellMinWidth: 80
//			,width:1400
			,toolbar: '#customerListTable-toolbar'
			,cols: [[
				{type: 'checkbox', fixed: 'left'}
				,{field:'name', title: '名称', align: 'center',width:280 }
                ,{field:'contacts', title: '联系人', align: 'center',minWidth:100 }
                ,{field:'mobile', title: '移动电话',event:'callMobile', align: 'center',minWidth:100 }
				,{field:'creditCode', title: '信用代码', align: 'center',minWidth:100 }
				,{field:'industry', title: '所属行业', align: 'center',minWidth:100 }
				,{field:'taxpayerType', title: '纳税人类型;1-一般;2-小规模', align: 'center',minWidth:100 }
				,{field:'department', title: '部门', align: 'center',minWidth:100 }
				,{field:'userName', title: '用户名称', align: 'center',minWidth:100 }
				,{field:'region', title: '区域', align: 'center',minWidth:100 }
				,{field:'intention', title: '意向度', align: 'center',minWidth:100 }
				,{title:'操作', toolbar: '#customerListTable-bar', width:120}
			]]
			,page: true,
			limit: 10,
			limits: layui.setter.limits,
		});
		var active = {
			showRec:function (obj) {
				window.formData = null;
				layer.open({
					type: 2
					,title: '客户信息'
					,content: 'customerShow.jsp'
					,maxmin: true
					,area: layui.setter.area
					,btn: ['关闭']
					,success:function(layero,index){
						window.formData = obj.data;
					}
				});
			},
			addRec: function(){
				window.formData = null;
				layer.open({
					type: 2
					,title: '客户信息'
					,content: 'customerForm.jsp'
					,maxmin: true
					,area: layui.setter.area
					,btn: ['确定', '取消']
					,yes: function(index, layero){
						var iframeWindow = window['layui-layer-iframe'+ index]
							,submit = layero.find('iframe').contents().find("#layuiadmin-app-form-submit");
						iframeWindow.layui.form.on('submit(layuiadmin-app-form-submit)', function(data){
							var field = data.field;
							var rtn = admin.syncReq(ctx+"/customer/customer/add",field);
							if(rtn && rtn.code==0){
								layer.msg('操作成功');
								active.reload();
								form.render();
								layer.close(index);
							}else{
								layer.msg('操作失败');
							}
						});
						submit.trigger('click');
					}
				});
			},
			editRec:function(obj){
				var rec = obj.data;
				window.formData = null;
				layer.open({
					type: 2
					,title: '客户信息'
					,content: 'customerForm.jsp'
					,maxmin: true
					,area: layui.setter.area
					,btn: ['确定', '取消']
					,success:function(layero,index){
						var body = layer.getChildFrame('body', index);
						var data = obj.data;
						window.formData = data;
						$.each(data,function(item){
							body.find("[name="+item+"]").val(data[item]);
						});
					}
					,yes: function(index, layero){
						var iframeWindow = window['layui-layer-iframe'+ index]
							,submit = layero.find('iframe').contents().find("#layuiadmin-app-form-edit");
						iframeWindow.layui.form.on('submit(layuiadmin-app-form-edit)', function(data){
							var field = data.field; 
							field.id = rec.id;
							var rtn = admin.syncReq(ctx+"/customer/customer/modify",field);
							if(rtn && rtn.code==0){
								layer.msg('操作成功');
								active.reload();
								form.render();
								layer.close(index);
							}else{
								layer.msg('操作失败');
							}
						});
						submit.trigger('click');
					}
				});
			},
			delRec:function () {
				var checkStatus = table.checkStatus('customerListTable')
				var recs = checkStatus.data;
				if(!recs || recs.length<=0){
					layer.msg('请至少选择一条记录');
					return;
				}
				layer.confirm('确定删除'+recs.length+'条记录?', function(index){
					var idArr = [];
					for(var i=0;i<recs.length;i++){
						var rec = recs[i];
						idArr.push(rec.id);
					}
					var rtn = admin.syncReq(ctx+"/customer/customer/deleteByBatch",{"ids":idArr.join(",")});
					if(rtn && rtn.code==0){
						layer.msg('操作成功');
						active.reload();
					}else{
						layer.msg('操作失败');
					}
				});
			},
			reload: function(){
				tableIns.reload();
			},
            callMobile:function (rec) {
                window.formData = null;
                layer.open({
                    type: 2
                    ,title: '拨打电话'
                    ,content: 'customerPhone.jsp'
                    ,maxmin: true
                    ,area: layui.setter.area
                    ,btn: ['拨打','挂断','关闭']
                    ,success:function(layero,index){
                        window.formData = rec;
                        window.formData = $.extend(rec,{
                            seatStatus:$("#seatStatus").val(),
                            callType:$("#callType").val(),
                        });
                    }
                    ,yes:function (index, layero) {
                        callPhone('',rec.mobile);
                        return false;
                    }
                    ,btn2:function (index, layero) {
                        hangUpPhone();
                        return false;
                    }
                    ,btn3:function (index, layero) {

                    }
                });
            }
		};
		table.on('toolbar(customerListTable)', function(obj){
			var checkStatus = table.checkStatus(obj.config.id);
			switch(obj.event){
				case 'addRec':
					active.addRec()
					break;
				case 'delRec':
					active.delRec(checkStatus)
					break;
			};
		});
		table.on('tool(customerListTable)', function(obj){
			var data = obj.data;
			if(obj.event === 'editRec'){
				active.editRec(obj);
			}else if(obj.event === 'showRec'){
				active.showRec(obj);
			}else if(obj.event==='callMobile'){
			    active.callMobile(data);
			}
		});
		form.on('submit(customer-list-search)', function(data){
			var field = data.field;
			table.reload('customerListTable', {
				where: field
			});
		});

        admin.seatData();
        setTimeout(function () {
            checkLogin();
        },1000)

	});
</script>
</body>
</html>
